﻿-- =============================================
-- Author:		<Author,XFL>
-- Create date: <Create Date,2012 02 03>
-- Description:	<Description,查询指定公司的员工，用于解决类似大区人资>
-- =============================================
CREATE PROCEDURE [dbo].[proc_Employee_Search_UserName_ComIDSearch] 
	(
		@SearchText nvarchar(50),
		@CompanyId int
	)
AS
BEGIN
	SET NOCOUNT ON;
		Select
		Id,
		UserName,
		EName,
		(case [state] when 5 then '<font color=red >(离职)</font>' else '' end) as StateName,
		CompanyId,
		DepartmentId,
		Isnull((Select PostName From Post Where Id=Employee.PostId),'...') As PostName,
		(Select CompanyName From Company Where Id=Employee.CompanyId) As CompanyName,
		Isnull((Select DName From Department Where Id=Employee.DepartmentId),'...') As DepartmentName,
		ZhiWu
		From Employee Where CompanyId=@companyId and DepartmentId<>0 and  (@SearchText is null Or EName like '%'+@SearchText+'%') --and State<>5
		
END
